home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50b Issue 142 (CD142b) (August 1998).iso / handson / Java / VCAdventure / ThingHolder.java < prev   
Encoding:
Java Source  |  1998-03-23  |  979 b   |  38 lines

  1. import java.util.*;
  2. public class ThingHolder extends Thing
  3. {
  4.     // This is a Thing that contains a Vector of other
  5.     // Things (its decsendents include Room and Person)
  6.     
  7.     private Vector things;
  8.         
  9.     ThingHolder( String aName, String aDescription ){
  10.     // constructor            
  11.         super( aName, aDescription );
  12.         this.things = new Vector(); // create a Vector of things
  13.     }
  14.      
  15.     // access methods
  16.     // things
  17.     Vector getthings() {        
  18.         return things;
  19.     }
  20.  
  21.     void setthings(Vector someThings) {
  22.         this.things = someThings;
  23.     }
  24.    
  25.    // add a single Thing to Vector things
  26.    void addthing( Thing t ) {
  27.      things.addElement( t );
  28.    }
  29.    
  30.    // add a whole Vector of Thing objects to Vector things
  31.    void addthings( Vector v ) {
  32.        for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
  33.             this.things.addElement((Thing)e.nextElement());
  34.        }
  35.    }
  36.  
  37.     
  38. }